package com.starsea.book.ui.newpage.adapter

import android.content.Context
import android.os.Bundle
import android.view.ViewGroup
import com.starsea.book.base.adapter.ItemViewHolder
import com.starsea.book.base.adapter.RecyclerAdapter
import com.starsea.book.databinding.ItemVipRightBinding
import com.starsea.book.ui.newpage.entity.FlowContentEntity
import com.starsea.book.ui.widget.recycler.ItemTouchCallback

class VipRightAdapter(
    context: Context
) :
    RecyclerAdapter<FlowContentEntity, ItemVipRightBinding>(context),
    ItemTouchCallback.Callback {


    override fun getViewBinding(parent: ViewGroup): ItemVipRightBinding {
        return ItemVipRightBinding.inflate(inflater, parent, false)
    }

    override fun registerListener(holder: ItemViewHolder, binding: ItemVipRightBinding) {

    }

    override fun convert(
        holder: ItemViewHolder,
        binding: ItemVipRightBinding,
        item: FlowContentEntity,
        payloads: MutableList<Any>
    ) {
        binding.run {
            val bundle = payloads.getOrNull(0) as? Bundle
            if (bundle == null) {
                tvRight.text = item.content ?: ""
                ivHeader.setImageResource(item.resImg)
//                tvPrice.text = item.price ?: ""
//                tvOriginPrice.text = item
//                是否热门 0:否;1:是

            } else {
                bundle.keySet().map {
                    when (it) {
                        "content" -> tvRight.text = item.content ?: ""
                    }
                }
            }
        }
    }


}